package com.zhuchaooasystem.adapter.holder;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.zhuchaooasystem.R;
import com.zhuchaooasystem.common.Key;
import com.zhuchaooasystem.entity.ServiceEntity;
import com.zhuchaooasystem.ui.home.service.ServiceDetailActivity;

/**
 * Created by zhangyajiang on 2016/12/29.
 */

public class ServiceViewHolder extends BaseViewHolder<ServiceEntity.ResultBean.SuccessfulBean.ResponseFlowBean> {

    TextView tv_code, tv_service_waring, tv_state,
            tv_service_name, tv_ContactName,
            tv_reservation, tv_address;

    LinearLayout layout;


    public ServiceViewHolder(final ViewGroup itemView) {
        super(itemView, R.layout.item_recycleview_service);

        layout = $(R.id.item_recycleview_service_layout);

        tv_code = $(R.id.item_recycleview_service_code);
        tv_service_waring = $(R.id.item_recycleview_service_service_waring);
        tv_state = $(R.id.item_recycleview_service_state);
        tv_service_name = $(R.id.item_recycleview_service_name);
        tv_ContactName = $(R.id.item_recycleview_service_contact_name);
        tv_reservation = $(R.id.item_recycleview_service_reservation);
        tv_address = $(R.id.item_recycleview_service_address);


    }

    @Override
    public void setData(final ServiceEntity.ResultBean.SuccessfulBean.ResponseFlowBean data) {
        super.setData(data);

        tv_code.setText(data.getID()+"");
        tv_service_waring.setText(data.getServiceWaring());
        tv_state.setText(data.getOrderStatus());
        tv_service_name.setText(data.getServiceName());
        if (data.getReservation() == null || data.getReservation().equals("")) {

            tv_reservation.setText("预约  " + "空");

        } else {

            tv_reservation.setText("预约  " + data.getReservation());

        }
        tv_ContactName.setText(data.getContactName());
        tv_address.setText(data.getAddress());

        layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                //跳转服务详情页面
                Intent intent = new Intent(itemView.getContext(), ServiceDetailActivity.class);

                intent.putExtra(Key.ID, data.getID() + "");
                intent.putExtra("orderState", data.getOrderStatus());
                itemView.getContext().startActivity(intent);

            }
        });
    }


}
